// var $parentNode = window.parent.document;

// function $childNode(name) {
//     return window.frames[name]
// }

// // tooltips
// $('.tooltip-demo').tooltip({
//     selector: "[data-toggle=tooltip]",
//     container: "body"
// });

// // 使用animation.css修改Bootstrap Modal
// $('.modal').appendTo("body");

// $("[data-toggle=popover]").popover();


//判断当前页面是否在iframe中
if (top == this) {
    var gohome = '<div class="gohome"><a class="animated bounceInUp" href="index.html?v=4.0" title="返回首页"><i class="fa fa-home"></i></a></div>';
    $('body').append(gohome);
}

//animation.css
function animationHover(element, animation) {
    element = $(element);
    element.hover(
        function () {
            element.addClass('animated ' + animation);
        },
        function () {
            //动画完成之前移除class
            window.setTimeout(function () {
                element.removeClass('animated ' + animation);
            }, 2000);
        });
}

//拖动面板
function WinMove() {
    var element = "[class*=col]";
    var handle = ".ibox-title";
    var connect = "[class*=col]";
    $(element).sortable({
            handle: handle,
            connectWith: connect,
            tolerance: 'pointer',
            forcePlaceholderSize: true,
            opacity: 0.8,
        })
        .disableSelection();
}

//保存记录
function saveRecordContents() {

    var eventName = $("#eventName").val();
    var recordTypeId = $("#recordTypeId").val();
    var happenTime = $("#happenTime").val();
    var happenStreet = $("#happenStreet").val();
    var responseUnit = $("#responseUnit").val();
    var principePhone = $("#principePhone").val();
    var remarkTime = $("#remarkTime").val();
    var remarkPeople = $("#remarkPeople").val();
    var detailAddress = $("#detailAddress").val();
    var situation = $("#situation").val();
    var solution = $("#solution").val();
    var files = $("#files").val();

    if (isNull(eventName)){
        alert("请输入事件名称");
        return;
    }

    if (isNull(recordTypeId)){
        alert("请选择事件类型");
        return;
    }

    if (isNull(happenStreet)){
        alert("请输入发生街道");
        return;
    }

    if (isNull(detailAddress)){
        alert("请输入详细地址");
        return;
    }

    if (isNull(responseUnit)){
        alert("请输入负责单位");
        return;
    }

    if (isNull(principePhone)){
        alert("请输入负责人联系电话");
        return;
    }

    if(!validNumber(principePhone)){
        alert("请输入数字");
        return;
    }

    if (isNull(remarkPeople)){
        alert("请输入备案人");
        return;
    }

    if (isNull(situation)){
        alert("请输入基本情况");
        return;
    }

    if (isNull(solution)){
        alert("请输入解决措施");
        return;
    }

    // if (isNull(files)){
    //     alert("请输入相关情况");
    //     return;
    // }

    var url = "/admin/eventRecordCreate/addNewEventRecord";
    var data = {
        "eventName": eventName,
        "recordTypeId": recordTypeId,
        "happenTime": happenTime,
        "happenStreet": happenStreet,
        "responseUnit": responseUnit,
        "principePhone": principePhone,
        "remarkTime": remarkTime,
        "remarkPeople": remarkPeople,
        "detailAddress": detailAddress,
        "situation": situation,
        "solution": solution,
        "files": files
    }

    console.log(data);

    $.ajax({
        url:url,
        type:"POST",
        dataType: 'json',
        contentType: "application/json",
        data: JSON.stringify(data),
        success:function (data) {

            $("#all-data").html(data);
            alert("添加成功");
            window.location.href="/admin/eventRecordCreate";

        },
        error:function () {
            alert("添加失败！");
        }

    });

}

//取消
function cancels() {

    location.reload();
}